<template>
  <!-- logo与搜索 -->
  <van-row>
    <van-col @click="toHome">
      <img class="logo" src="@/views/home/images/logo.png" alt="">
    </van-col>
    <van-col>
      <van-search class="headerSearch" v-model="keyword" shape="round" @click-input="click"
        placeholder="搜索商品,共12444款好物" />
    </van-col>
    <van-col>
      <div class="loginBtn" @click="toLogin">登录</div>
    </van-col>
  </van-row>
  <!-- 滚动标签页 -->
  <van-tabs class="tabs" title-active-color="#d43c33" color="#d43c33" >
    <van-tab title="推荐" :name="101" to="/">
    </van-tab>
    <van-tab v-for="nav in navList" :key="nav.id" :title="nav.name" :name="nav.id"
      :url="`/item/homeList?categoryId=${nav.id}`">
    </van-tab>
  </van-tabs>
</template>

<script setup lang='ts'>
import type { CateGoryListModel } from '@/api/home';
import { ref } from 'vue';

import { useRoute, useRouter } from 'vue-router';

const keyword = ''
const router = useRouter()
const route = useRoute()
const click = () => {
  // console.log('test');
  router.push('/search')

}

const props = defineProps<{
  navList: CateGoryListModel,
}>()

// 登录按钮的回调
const toLogin = () => {
  router.push('/login')
}

// 点击图标跳转到首页
const toHome = ()=>{
  router.push('/')
}


</script>

<style scoped>
.logo {
  width: 2rem;
  display: inline-block;
  margin: .35rem 0 0 .4rem;
}

.headerSearch {
  width: 6rem;
  border: 0;

  margin: -0.1rem 0 0 0;
  padding: .3rem;
  border-radius: .27rem;
  --van-search-content-background: #ededed;
  --van-search-action-text-color: #000;
}

.van-search__content {
  border-radius: 1rem;
  background: #f00;
}

.loginBtn {
  margin: .4rem 0 0 .1rem;
  width: 1rem;
  height: .53rem;
  color: rgb(199, 43, 43);
  line-height: .53rem;
  text-align: center;
  font-size: .22rem;
  border-radius: .1rem;
  border: .03rem solid rgb(199, 43, 43);
}

/* 导航栏相关样式 */
.tabs:deep(.van-tabs__line) {
  position: absolute;
  bottom: .6rem;
  left: 0;
  z-index: 1;
  width: var(--van-tabs-bottom-bar-width);
  height: var(--van-tabs-bottom-bar-height);
  background: var(--van-tabs-bottom-bar-color);
  border-radius: var(--van-tabs-bottom-bar-height);
}
</style>